<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.util.*, javax.servlet.*, javax.servlet.http.*" %>
<%@ page import="cn.edu.lingnan.pojo.ProjectAdult " %>
<%@ page import="cn.edu.lingnan.pojo.Project" %>
<%@ page import="cn.edu.lingnan.pojo.User" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>审核创建项目</title>
    <style>
        body {
            font-family: Arial, sans-serif;
        }
        table {
            width: 100%;
            border-collapse: collapse;
            margin-bottom: 20px;
        }
        table, th, td {
            border: 1px solid #ddd;
        }
        th, td {
            padding: 12px;
            text-align: left;
        }
        th {
            background-color: #f2f2f2;
        }
        button {
            background-color: #4CAF50;
            color: white;
            border: none;
            padding: 10px 20px;
            cursor: pointer;
            border-radius: 5px;
            transition: background-color 0.3s ease;
        }
        button:hover {
            background-color: #45a049;
        }
        .reject-button {
            background-color: #f44336;
        }
        .reject-button:hover {
            background-color: #e53935;
        }
        .modal {
            display: none;
            position: fixed;
            z-index: 1;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            overflow: auto;
            background-color: rgba(0, 0, 0, 0.4);
            padding-top: 60px;
            transition: all 0.5s ease;
        }
        .modal-content {
            background-color: #fff;
            margin: 5% auto;
            padding: 20px;
            border: 1px solid #888;
            width: 80%;
            max-width: 500px;
            border-radius: 10px;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
            animation: slide-in 0.5s ease-out;
        }
        @keyframes slide-in {
            from {
                transform: translateY(-50px);
                opacity: 0;
            }
            to {
                transform: translateY(0);
                opacity: 1;
            }
        }
        .close {
            color: #aaa;
            float: right;
            font-size: 28px;
            font-weight: bold;
        }
        .close:hover,
        .close:focus {
            color: black;
            text-decoration: none;
            cursor: pointer;
        }
        textarea {
            width: 100%;
            padding: 10px;
            border: 1px solid #ddd;
            border-radius: 5px;
            resize: vertical;
            margin-top: 10px;
        }
        textarea:focus {
            border-color: #4CAF50;
            outline: none;
        }
    </style>
</head>
<body>
<h1>审核创建项目</h1>
<table>
    <tr>
        <th>项目ID</th>
        <th>项目名称</th>
        <th>导师ID</th>
        <th>导师姓名</th>
        <th>类型</th>
        <th>开始时间</th>
        <th>结束时间</th>
        <th>描述</th>
        <th>成员</th>
        <th>操作</th>
    </tr>
    <%

        User user = (User) session.getAttribute("user");
        List<Project> projects = (List<Project>) session.getAttribute("studnetCreateProject");

        if (projects != null) {
            for (Project project : projects) {
    %>
    <tr>
        <td><%= project.getProtectId() %></td>
        <td><%= project.getProjectName() %></td>
        <td><%= project.getPostId() %></td>
        <td><%= project.getPostName() %></td>
        <td><%= project.getType() %></td>
        <td><%= project.getStartTime() %></td>
        <td><%= project.getEndTime() %></td>
        <td><%= project.getDescription() %></td>
        <td><%= project.getMembers() %></td>
        <td>
            <form action="AgreeStudentCreateProject" method="post" style="display:inline;">
                <input type="hidden" name="projectId" value="<%= project.getProtectId() %>">
                <button type="submit">通过创建</button>
            </form>
            <button class="reject-button" onclick="openModal('<%= project.getProtectId() %>')">驳回</button>
        </td>
    </tr>
    <%
            }
        }
    %>
</table>

<div id="rejectModal" class="modal">
    <div class="modal-content">
        <span class="close" onclick="closeModal()">&times;</span>
        <form id="rejectForm" action="rejectproject" method="post" onsubmit="return confirmRejection()">
            <input type="hidden" name="projectId" id="modalProjectId">
            <label for="rejectionReason">驳回原因:</label>
            <textarea id="rejectionReason" name="rejectionReason" rows="4"  style="margin-left: -10px" required></textarea><br><br>
            <button type="submit">提交</button>
        </form>
    </div>
</div>

<script>
    function openModal(projectId) {
        document.getElementById("modalProjectId").value = projectId;
        document.getElementById("rejectModal").style.display = "block";
    }

    function closeModal() {
        document.getElementById("rejectModal").style.display = "none";
    }

    function confirmRejection() {
        return confirm("确定要驳回此项目吗？");
    }

    window.onclick = function(event) {
        if (event.target == document.getElementById("rejectModal")) {
            closeModal();
        }
    }
</script>

</body>
</html>
